echo Connected to $1
first=1
ret=0
while [ $ret -eq 0 ]; do
	echo :::Ready
	read cmd
	ret=$?
	if [ "$first" ]; then
		echo :::Opening output
		exec 4>"$2"
	fi
	echo :::Sending
	echo $cmd >&4
	if [ "$first" ]; then
		echo :::Opening input
		exec 3<"$1"
	fi
	echo :::Reading
	while read -t 1 <&3; do
		echo $REPLY
	done
	first=
done
echo :::Closing pipes
exec 3<&- 4>&-
